import { listOptions } from '@/api/login/index.js';
const state = {
  request: false,
  optionList: []

};
const mutations = {
  changeRequest: (state, bool) => {
    state.request = bool;
  },
  // 保存所有
  setOptionList: (state, data) => {
    state.optionList = data;
  }
};
const actions = {
  getListOptions({ commit, state }) {
    !state.request && listOptions({
      timestamp: 123,
      resultAsTree: true
    }).then(res => {
      commit('changeRequest', true);
      const { success, data } = res;
      if (success) {
        commit('setOptionList', data);
      }
    });
  }
};
export default {
  namespaced: true,
  state,
  mutations,
  actions
};
